#ifndef _CMD_PARSER_HPP_20120513
#define _CMD_PARSER_HPP_20120513

#include "base.hpp"

#include <stdint.h>
#include "cmd_value.hpp"
#include "abstract_parser.hpp"

using namespace mina;

namespace cmd
{
	class CmdParser : public AbstractParser
	{
		public :
			int encode(ListBuffer & listbuffer, void * data);
			
			int  decode(ListBuffer & listbuffer, void *& data);

			bool frame(ListBuffer & listbuffer);
		
		public :	
			static uint32_t get_magic(ListBuffer & listbuffer);
			static uint32_t get_length(ListBuffer & listbuffer);
			static cmd_0_type get_cmd_0(ListBuffer & listbuffer);
			static cmd_1_type get_cmd_1(ListBuffer & listbuffer);
		
		public :
			const static uint32_t MAX_CMD_SIZE = 1024 * 1024;

            char _buffer[MAX_CMD_SIZE];
	};
};

#endif

